#include "Stage.h"

CStage::CStage(void)
{
	//CCTextureCache::sharedTextureCache()->addImage("image/bg/stage_bg.png");
}

CStage::~CStage(void)
{
	//CCTextureCache::sharedTextureCache()->removeTextureForKey("image/bg/stage_bg.png");
}

bool CStage::init()
{
	bool bRet = false;

	do 
	{
		/*
			parent init call
		*/
		
		CCLayer::init();

		// success
		bRet = true;

	} while(0);

	return bRet;
}

void CStage::onEnter()
{
	CCSprite* pSprite = CCSprite::spriteWithFile("image/bg/stage_bg.png");
	pSprite->setAnchorPoint(CCPointZero);
	pSprite->setPosition(CCPointZero);
	addChild(pSprite);

	m_pOutletMgr = COutlet_Manager::node();
	m_pOutletMgr->setAnchorPoint(CCPointZero);
	m_pOutletMgr->setPosition(CCPointZero);
	addChild(m_pOutletMgr);


	m_pBlockMgr = CBlock_Manager::node();
	m_pBlockMgr->setAnchorPoint(CCPointZero);
	m_pBlockMgr->setPosition(CCPointZero);
	addChild(m_pBlockMgr);

	for(int i=0; i<m_pOutletMgr->GetOutletCount(); i++)
	{
		Tree* pTree = dynamic_cast<Tree*>(m_pOutletMgr->GetOutlet(i));
		m_TreeObserver.RegistHeader(pTree);
	}

	CCLayer::onEnter();
}

void CStage::onExit()
{

	CCLayer::onExit();
}